/* p7_6.c: DAC programming to generate sine wave using math functions */

#include <math.h>

#define WAVEFORM_LENGTH 1024
int sinewave[WAVEFORM_LENGTH];

int main(void)
{
    int i;
    float fRadians;
#ifndef M_PI
    const float M_PI = 4 * atan(1.0);
#endif

    /* construct data table for a sine wave */
    fRadians = ((2 * M_PI) / WAVEFORM_LENGTH);
    for (i = 0; i < WAVEFORM_LENGTH; i++)
    {
        sinewave[i] = 500 * (sinf(fRadians * i) + 1);
    }
}